/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fh.view.player;

import fh.view.running.CurrentTourneyOverview;
import fh.controller.PlayerController;
import fh.model.Player;
import fh.view.*;
import javax.swing.JOptionPane;

/**
 *
 * @author Dikkehein
 */
public class AddPlayer extends javax.swing.JFrame {

    Player aPlayer;
    PlayerController pc;

    /**
     * Creates new form AddPlayer
     */
    public AddPlayer() {
        aPlayer = new Player();
        pc = new PlayerController();
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        CurrentTourneyButton = new javax.swing.JButton();
        LocationEventMainButton = new javax.swing.JButton();
        PlayerOverviewButton = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        FirstNameAddPlayerField = new javax.swing.JTextField();
        LastNameAddPlayerField = new javax.swing.JTextField();
        AddressAddPlayerField = new javax.swing.JTextField();
        ZipAddPlayerField = new javax.swing.JTextField();
        CityAddPlayerField = new javax.swing.JTextField();
        PhoneAddPlayerField = new javax.swing.JTextField();
        EmailAddPlayerfield = new javax.swing.JTextField();
        VIPPlayerCheckBox = new javax.swing.JCheckBox();
        CancelAddPlayerButton = new javax.swing.JButton();
        AddPlayerButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Toevoegen speler");
        setMaximumSize(new java.awt.Dimension(800, 600));
        setMinimumSize(new java.awt.Dimension(800, 600));
        setResizable(false);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 30)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Full House");
        jLabel1.setToolTipText("");

        CurrentTourneyButton.setText("Toernooi runnen");
        CurrentTourneyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CurrentTourneyButtonActionPerformed(evt);
            }
        });

        LocationEventMainButton.setText("Locatie & Event");
        LocationEventMainButton.setMaximumSize(new java.awt.Dimension(111, 23));
        LocationEventMainButton.setMinimumSize(new java.awt.Dimension(111, 23));
        LocationEventMainButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LocationEventMainButtonActionPerformed(evt);
            }
        });

        PlayerOverviewButton.setText("Speler beheer");
        PlayerOverviewButton.setMaximumSize(new java.awt.Dimension(111, 23));
        PlayerOverviewButton.setMinimumSize(new java.awt.Dimension(111, 23));
        PlayerOverviewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PlayerOverviewButtonActionPerformed(evt);
            }
        });

        jLabel2.setText("Voornaam:");

        jLabel3.setText("Achternaam:");

        jLabel4.setText("Adres:");

        jLabel5.setText("Postcode:");

        jLabel6.setText("Stad:");

        jLabel7.setText("Telefoonnummer:");

        jLabel8.setText("E-mail:");

        jLabel9.setText("Bekende speler:");

        FirstNameAddPlayerField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FirstNameAddPlayerFieldActionPerformed(evt);
            }
        });

        LastNameAddPlayerField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LastNameAddPlayerFieldActionPerformed(evt);
            }
        });

        AddressAddPlayerField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddressAddPlayerFieldActionPerformed(evt);
            }
        });

        ZipAddPlayerField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ZipAddPlayerFieldActionPerformed(evt);
            }
        });

        CityAddPlayerField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CityAddPlayerFieldActionPerformed(evt);
            }
        });

        PhoneAddPlayerField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PhoneAddPlayerFieldActionPerformed(evt);
            }
        });

        EmailAddPlayerfield.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EmailAddPlayerfieldActionPerformed(evt);
            }
        });

        VIPPlayerCheckBox.setToolTipText("Aangevinkt betekend bekende speler");
        VIPPlayerCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                VIPPlayerCheckBoxActionPerformed(evt);
            }
        });

        CancelAddPlayerButton.setText("Annuleren");
        CancelAddPlayerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelAddPlayerButtonActionPerformed(evt);
            }
        });

        AddPlayerButton.setText("Aanmaken");
        AddPlayerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AddPlayerButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addComponent(LocationEventMainButton, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(PlayerOverviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(CurrentTourneyButton, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 67, Short.MAX_VALUE))
                            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(83, 83, 83)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(jLabel8)
                            .addComponent(jLabel9))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(39, 39, 39)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(FirstNameAddPlayerField)
                                    .addComponent(LastNameAddPlayerField)
                                    .addComponent(AddressAddPlayerField)
                                    .addComponent(ZipAddPlayerField)
                                    .addComponent(CityAddPlayerField, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(40, 40, 40)
                                .addComponent(VIPPlayerCheckBox))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(PhoneAddPlayerField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(EmailAddPlayerfield, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(AddPlayerButton)
                .addGap(37, 37, 37)
                .addComponent(CancelAddPlayerButton)
                .addGap(90, 90, 90))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(CurrentTourneyButton, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(PlayerOverviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(LocationEventMainButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(LastNameAddPlayerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(AddressAddPlayerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(ZipAddPlayerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(CityAddPlayerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(PhoneAddPlayerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(EmailAddPlayerfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(VIPPlayerCheckBox)))
                    .addComponent(FirstNameAddPlayerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(CancelAddPlayerButton)
                    .addComponent(AddPlayerButton))
                .addGap(99, 99, 99))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void CurrentTourneyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CurrentTourneyButtonActionPerformed
        new CurrentTourneyOverview().setVisible(true);
        this.dispose();
   }//GEN-LAST:event_CurrentTourneyButtonActionPerformed

    private void LocationEventMainButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LocationEventMainButtonActionPerformed
        new LocationEventOverview().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_LocationEventMainButtonActionPerformed

    private void PlayerOverviewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PlayerOverviewButtonActionPerformed
        new PlayerOverview().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_PlayerOverviewButtonActionPerformed

    private void VIPPlayerCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VIPPlayerCheckBoxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_VIPPlayerCheckBoxActionPerformed

    private void CancelAddPlayerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelAddPlayerButtonActionPerformed
        new PlayerOverview().setVisible(true);
        this.dispose();
    }//GEN-LAST:event_CancelAddPlayerButtonActionPerformed

    private void AddPlayerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddPlayerButtonActionPerformed
        if (FirstNameAddPlayerField.getText().equals("") || AddressAddPlayerField.getText().equals("") || LastNameAddPlayerField.getText().equals("") || ZipAddPlayerField.getText().equals("") || EmailAddPlayerfield.getText().equals("") || CityAddPlayerField.getText().equals("") || PhoneAddPlayerField.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Vul alle velden in");
        } else {

            aPlayer.setFirstname(FirstNameAddPlayerField.getText());
            aPlayer.setLastname(LastNameAddPlayerField.getText());
            aPlayer.setAddress(AddressAddPlayerField.getText());
            aPlayer.setZipcode(ZipAddPlayerField.getText());
            aPlayer.setCity(CityAddPlayerField.getText());
            aPlayer.setPhonenumber(PhoneAddPlayerField.getText());
            aPlayer.setEmail(EmailAddPlayerfield.getText());
            aPlayer.setVip(VIPPlayerCheckBox.isSelected());
            int rating = 1000;
            aPlayer.setRating(rating);
            int money_won = 0;
            aPlayer.setMoney_won(money_won);
            pc.insertPlayer(aPlayer);

            new PlayerOverview().setVisible(true);
            this.dispose();
        }
    }//GEN-LAST:event_AddPlayerButtonActionPerformed

    private void LastNameAddPlayerFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LastNameAddPlayerFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_LastNameAddPlayerFieldActionPerformed

    private void ZipAddPlayerFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ZipAddPlayerFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ZipAddPlayerFieldActionPerformed

    private void EmailAddPlayerfieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EmailAddPlayerfieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_EmailAddPlayerfieldActionPerformed

    private void FirstNameAddPlayerFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FirstNameAddPlayerFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_FirstNameAddPlayerFieldActionPerformed

    private void AddressAddPlayerFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AddressAddPlayerFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_AddressAddPlayerFieldActionPerformed

    private void CityAddPlayerFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CityAddPlayerFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_CityAddPlayerFieldActionPerformed

    private void PhoneAddPlayerFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PhoneAddPlayerFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_PhoneAddPlayerFieldActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AddPlayer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AddPlayer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AddPlayer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AddPlayer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new AddPlayer().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AddPlayerButton;
    private javax.swing.JTextField AddressAddPlayerField;
    private javax.swing.JButton CancelAddPlayerButton;
    private javax.swing.JTextField CityAddPlayerField;
    private javax.swing.JButton CurrentTourneyButton;
    private javax.swing.JTextField EmailAddPlayerfield;
    private javax.swing.JTextField FirstNameAddPlayerField;
    private javax.swing.JTextField LastNameAddPlayerField;
    private javax.swing.JButton LocationEventMainButton;
    private javax.swing.JTextField PhoneAddPlayerField;
    private javax.swing.JButton PlayerOverviewButton;
    private javax.swing.JCheckBox VIPPlayerCheckBox;
    private javax.swing.JTextField ZipAddPlayerField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    // End of variables declaration//GEN-END:variables
}
